package service;

import dao.Privatedao;
import dao.Userdao;
import vo.Private;
import vo.ResultInfo;
import vo.User;

import java.sql.SQLException;

public class Privateservice {
    public ResultInfo<User> check(String privatename) throws SQLException {
        ResultInfo<User> resultInfo=new ResultInfo<>();
        if(privatename==null ||privatename.isEmpty() ){
            resultInfo.setCode(0);
            resultInfo.setWhich("对象为空");
            return resultInfo;
        }
        Userdao userdao=new Userdao();
        User user=userdao.getUserByUserName(privatename);
        if(user==null){
            resultInfo.setCode(0);
            resultInfo.setWhich("对象不存在");
            return resultInfo;
        }
        resultInfo.setCode(1);
        resultInfo.setResult(user);
        return resultInfo;
    }
}
